package com.kirayous.common.valid;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.ElementType.TYPE_USE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @author KiraYous
 * @version V1.0
 * @Package com.kirayous.common.valid
 * @date 2021/9/17 16:23
 *
 * 自定义校验注解
 * 需要使用到javax.validation的包
 */
@Documented
@Constraint(validatedBy = { ListValueConstraintValidator.class })//设置通过哪个校验器进行校验
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
public @interface ListValue {
    /*默认是去找当前模块下的resources/ValidationMessages.properties文件
    并找到com.kirayous.common.valid.ListValue.message对应的字段*/
    String message() default "{com.kirayous.common.valid.ListValue.message}";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };

    int[] vals() default { };
}